Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::function for GLUI callbacks #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nigels-com
Copy link
Collaborator

This change replaces GLUI_CB and the associated IDs and pointers with simply std::function<void(void)>. This allows for using C++ lambdas for GLUI callbacks, including std::bind.

For example:

new GLUI_Button( glui, "Quit", []() { printf("Exit\n"); exit(0); } );

Copy link

@djwebb djwebb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a c++ idiot like me, could you explain how the callbacks work here - for example at lines 243 and 244 of the original code how does "& {printf etc." link to the callback routine.
Also won't these changes require a reqrite of the manual?
David.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants